﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCChangeToChuc.ascx.cs"
    Inherits="Viewer.UserControls.UCChangeToChuc" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<ext:XScript ID="XScipt1" runat="server">
    <script type="text/javascript">
        var refreshTree = function(tree, result) {
            var nodes = eval(result);
            if (nodes.length > 0) {
                tree.initChildren(nodes);
            }
            else {
                tree.getRootNode().removeChildren();
            }
        }
        function ConfirmDelete(id) {
            Ext.MessageBox.confirm('Thông báo', 'Bạn có chắc chắn xóa record này ko?', function doDel2(btn) {
                if (btn == 'yes') {
                    Ext.net.DirectMethods.DeleteTochuc(id);
                }
            });
        }
        function CheckDuplicate(nodeId) {
       
          if(nodeId==#{hdTochucIdChaCu}.getValue())
          {
        
          if(#{hdStatus}.getValue()=='Tochuc')
          {
             Ext.MessageBox.alert('Thông báo', 'Tổ chức không hợp lê. Xin vui lòng chọn tổ chức khác.');
          }
          else
          {
            Ext.MessageBox.alert('Thông báo', 'Chức năng không hợp lê. Xin vui lòng chọn chức năng khác.');
          }
              #{Button2}.setDisabled(true);
          }
          else
          {
               #{Button2}.setDisabled(false);
          }
        }
    </script>
</ext:XScript>
<ext:Hidden ID="hdTochucIdChaCu" runat="server">
</ext:Hidden>
<ext:Hidden ID="hdTochucIdChaMoi" runat="server">
</ext:Hidden>
<ext:Hidden ID="hdStatus" runat="server">
</ext:Hidden>
<ext:Hidden ID="hdTochucId" runat="server">
</ext:Hidden>
<ext:Window ID="wdChangTochuc" runat="server" Width="450" Height="400" Modal="true" 
    CMargins="0" Region="North" Closable="false" Hidden="true" HideBorders="True"
    Border="false" Plain="true" Resizable="true" Frame="false" Title="Thay đổi tổ chức trực thuộc"
    Icon="User">
    <Content>
        <ext:Panel ID="Panel1" runat="server" Frame="false">
            <Content>
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <ext:Label ID="Label2" runat="server">
                            </ext:Label>
                            <ext:Label ID="lblCu" runat="server">
                            </ext:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ext:Label ID="Label1" runat="server">
                            </ext:Label>
                            <ext:Label ID="lblMoi" runat="server">
                            </ext:Label>
                        </td>
                    </tr>
                </table>
            </Content>
        </ext:Panel>
        <hr style="color: #c6d7e7" />
        <ext:TreePanel ID="trPanel" runat="server" Icon="ChartOrganisation" Height="290" AutoScroll="true">
            <Listeners>
                <Click Handler="#{hdTochucIdChaMoi}.setValue(node.id);
                                    #{lblMoi}.setText(node.text);CheckDuplicate(node.id);" />
            </Listeners>
        </ext:TreePanel>
    </Content>
    <Buttons>
        <ext:Button ID="Button2" runat="server" Text="Thay đổi tổ chức" Icon="Disk">
            <DirectEvents>
                <Click OnEvent="btnChon_Click">
                </Click>
            </DirectEvents>
        </ext:Button>
        <ext:Button ID="Button1" runat="server" Text="Đóng" Icon="Cancel">
            <Listeners>
                <Click Handler="#{wdChangTochuc}.hide();" />
            </Listeners>
        </ext:Button>
    </Buttons>
</ext:Window>
